<template>
    <div class="header-super-store d-none d-xl-block d-lg-none d-md-block">
        <div class="dropdown">
            <button class="dropdown-toggle" @click.prevent="getsuperstorelist" type="button" id="dropdownMenuButton4" data-toggle="dropdown"
                aria-haspopup="true" aria-expanded="false"><i class="flaticon-shop"></i> 连锁超市</button>
            <div class="dropdown-menu" aria-labelledby="dropdownMenuButton4">
                <router-link class="dropdown-item"
                 v-for="superstore  in superstorelist"
                  :to="`${routes.superstore}/${superstore.id}/${superstore.name}`" 
                  :key="superstore.id">
                  {{ superstore.name }}</router-link>
               
                <router-link v-if="superstorelist.length>0" style="color: green;" class="dropdown-item" :to="routes.superstoreall">全部</router-link>
            </div>
        </div>
    </div>
</template>

<script>
import { getsuperstorelist } from '@/api/head';
export default {
        data() {
            return {
                superstorelist:[],
                gtstorecount:5,
                routes:{
                    superstoreall:'/superstore/all',
                    superstore:'/superstore',
                    open:false
                }
            }
        },
        methods: {
            getsuperstorelist(){
                this.open=!this.open
                    if(open){
                        
                        getsuperstorelist(this.gtstorecount).then(list=>{
                        this.superstorelist=list
                    })
                    }else{
                        this.superstorelist.length=0
                    }
            }
        },
    
}
</script>

<style>

</style>